package com.springbootmybatis.mapper;

import com.springbootmybatis.pojo.Book;
import com.springbootmybatis.sql.SqlContext;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface BookMapper {
	@Select("select * from book")
	List<Book> findAllBook();
	@Select("select * from book where id=#{id}")
	Book findBookById(Integer id);
	@SelectProvider(method = "searchBookSql",type = SqlContext.class )
	List<Book> searchBooks(Book book);
	@Insert("insert into book values (null,#{name},#{price},#{category},#{pnum},#{imgurl},#{description},#{author},#{sales})")
	Integer addBook(Book book);
	@Update("update book set name=#{name},price=#{price},category=#{catrgory},pnum=#{pnum},imgurl=#{imgurl},author=#{author},sales=#{sales} where id=#{id}")
	Integer updateBook(Book book);
	@Delete("delete from book where id=#{id}")
	Integer deleteById(Integer id);
}
